<template>
  <Chart :chart-data="chartData" />
  <!-- <div class="screen-bottom-left">
    <div class="screen-bottom-header flex-l">
      <div class="header-left flex-c">
        <i class="iconfont icon-align-left"></i>
      </div>
      <div class="header-right flex-l">
        <span class="header-title" @click="$router.push('/')">本年违章查处报表</span>
        <dv-decoration-1 class="dv-dec-1" />
      </div>
    </div>
    <div class="screen-bottom-chart">
      <Chart :chart-data="chartData" />
    </div>
  </div> -->
</template>

<script setup lang="ts">
import Chart from './chart/ChartBottomLeft.vue'
import { defineComponent, reactive, onMounted } from 'vue'
import { getCurrentYearReportApi } from '@/api/screen'
const chartData = reactive({
  category: [] as Array<string>,
  lineData: [],
  barData: [] as Array<number>,
  rateData: [] as Array<string>
})

const getCurrentYearReport = async () => {
  const res = await getCurrentYearReportApi()
  console.log(res)
  res.data?.map((item) => {
    chartData.barData.push(item.count)
    chartData.category.push(item.depName)
  })
}
getCurrentYearReport()

// methods
const setData = () => {
  for (let i = 0; i < chartData.barData.length - 1; i++) {
    const rate = chartData.barData[i] / chartData.lineData[i]
    chartData.rateData.push(rate.toFixed(2))
  }
}

// 生命周期
onMounted(() => {
  // setData()
})
</script>

<style lang="scss" scoped>
@import '/src/assets/scss/common/variables.scss';
.flex-l {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
}
.screen-bottom-left {
  // height: $box-height6 - 10px;
  // width: $box-width3;
  // background-color: $theme-sub-color;
  margin: 15px 5px;
  border-radius: 20px;

  .screen-bottom-header {
    height: $chart-header-height;

    .header-left {
      // width: 40px;
      width: 10px;
    }

    .header-right {
      width: calc(100% - 40px);

      .header-title {
        color: #fff;
        font-size: $base-font-size;
        cursor: pointer;
      }

      .dv-dec-1 {
        width: 50px;
        height: 20px;
        margin-left: 10px;
      }
    }
  }
}
</style>
